import json
from fastapi import APIRouter, Query
from fastapi.responses import JSONResponse
from typing import Optional
from langchain_community.llms import Ollama
from langchain_core.messages import SystemMessage, HumanMessage
from langchain_core.prompts import PromptTemplate

ollama = Ollama(base_url='http://172.16.21.38:11436', model="qwen3:0.6b")
router = APIRouter()

@router.get("/assistant_role")
async def assistant_role():
    messages = [
        SystemMessage(content="你是一位精通中西文化的起名大师，回答必须用中文。"),
        HumanMessage(content="请给我三个具有意大利风格的男孩名字"),
        # 这里我们手动加入 assistant 历史回答，模拟上下文
        {"role": "assistant", "content": "卢卡, 马尔科, 乔瓦尼"},
        HumanMessage(content="再给我三个法国风格的")
    ]
    response = ollama.invoke(messages)
    return {"role": "assistant_demo", "response": response}
